package iblink.junit;

import iblink.adapter.IBClient;
import iblink.adapter.IBClientFactory;
import iblink.adapter.IBFacade;
import iblink.adapter.IBFacadeFactory;
import packutil.idgen.DefaultIdGeneratorFactory;
import packutil.idgen.FileSavedIdGenerator;
import packutil.idgen.IIdGenerator;
import packutil.idgen.IIdGeneratorFactory;
import packutil.throttle.IThrottleFactory;
import packutil.throttle.ThrottleFactoryDefaultImpl;

public class TestHelper {

	private static final String ibHost = "";
	private static final int ibPort = 4002;

	public static IBFacade getIBFacade() {
		String testFilePath = "C:\\Windows\\Temp\\r";
		IIdGeneratorFactory idGen = new DefaultIdGeneratorFactory();
		IBClientFactory clientFactory = getIBClientFactory();
		IBFacadeFactory fact = new IBFacadeFactory(clientFactory, idGen);
		return fact.createIBFacade();
	}

	public static IBClientFactory getIBClientFactory() {
		String testFilePath = "C:\\Windows\\Temp\\packutiltmp1112";
		IIdGenerator idGen = new FileSavedIdGenerator(testFilePath);
		IThrottleFactory throttleFactory = new ThrottleFactoryDefaultImpl();
		IBClientFactory clientFactory = new IBClientFactory(idGen,
				throttleFactory, ibHost, ibPort);
		return clientFactory;
	}

	public static IBClient getIBClient() {
		return getIBClientFactory().createIBClient();
	}


}
